/*------------------- COPYRIGHT AND TRADEMARK INFORMATION ------------------+
 |                                                                          |
 |    VoCon (R) 3200 Embedded Development System                            |
 |                                                                          |
 |    (c) 2008 Nuance Communications, Inc. All rights reserved.             |
 |                                                                          |
 |    Nuance, the Nuance logo and VoCon are trademarks and/or registered    |
 |    trademarks of Nuance Communications, Inc. or its affiliates in the    |
 |    United States and/or other countries.                                 |
 |                                                                          |
 +--------------------------------------------------------------------------*/
#include "vocon3200_asr.h"
#include "vocon3200_sem.h"

struct ASR2SEM_S2 {
  LH_HEAP_INTERFACE   heapInterface;          /* The heap allocation interface used for creating the Sem input. */
  void*               pHeapInst;              /* The heap instance. */
  LH_OBJECT           hSemProc;               /* Handle of the SemProc object used for processing. */
  LH_SEMPROC_NBESTRESULT_HYPOTHESIS* aHypos;  /* The array of hypotheses. */
  LH_SEMPROC_CLASS*     pWordClasses; /* Word classes from sem*/
  unsigned long       nbrClasses;             /* Number of word classes*/
  unsigned long       nbrHypos;               /* The length of the array of hypotheses. */
  LH_SEMPROC_FEATURE* aFeatures;              /* Array of SemProc features configured by the sem buffer. */
  unsigned long       nbrFeatures;            /* Number of features configures by the sem buffer. */
};
typedef struct ASR2SEM_S2 ASR2SEM2;

typedef struct ASR2SEM_S2* PASR2SEM2;
/**@}*/

/**\ingroup External_Components_Asr2Sem
@{*/
/** \brief Create an Asr2Sem instance.
 * 
 * This function creates the Asr2Sem handle. After this call, it is ready to
 * receive ASR results.
 * 
 * \param[in] pHeapInterface The heap allocation interface to use for the Sem input.
 * \param[in] pHeapInst The heap instance. This is opaque data for the engine.
 * \param[in] hSemProc The SemProc object to use for processing the ASR output. Implements the \ref VoCon_Interfaces_SemProc
 * \param[out] phAsr2Sem Handle to the created ASR2SEM instance.
 *
 * \return see \ref ErrorHandling
 */
LH_ERROR a2s_CreateAsr2Sem2(LH_HEAP_INTERFACE* pHeapInterface, void* pHeapInst,
                           LH_OBJECT hSemProc, PASR2SEM2* phAsr2Sem);
/**@}*/

/**\ingroup External_Components_Asr2Sem
@{*/
/** \brief Add an ASR result for Sem processing.
 * 
 * \param[in]    hAsr2Sem The Asr2Sem handle.
 * \param[in]    hNBestResult An ASR NBestResult handle. 
 *               This object must implement the \ref VoCon_Interfaces_NBestResult.
 *               The relevant contents of this object are copied, so it can be closed after
 *               this call.
 *
 * \return see \ref ErrorHandling
 */
LH_ERROR a2s_Asr2SemAddNBestResult2(PASR2SEM2 hAsr2Sem,
                                         LH_OBJECT hNBestResult);
/**@}*/

/**\ingroup External_Components_Asr2Sem
@{*/
/** \brief Process the collected results with the SemProc.
 * 
 * This function calls the SemProc with the collected results, and cleans up the collected
 * results array. After this call, a semantic classification result can be requested 
 * using \ref lh_SemProcCreateSemResult.
 * 
 * \param[in]    hAsr2Sem The Asr2Sem handle.
 *
 * \return see \ref ErrorHandling
 */
LH_ERROR a2s_Asr2SemProcess2(PASR2SEM2 hAsr2Sem);
/**@}*/

/**\ingroup External_Components_Asr2Sem
@{*/
/** \brief Close the Asr2Sem instance.
 * 
 * \param[in,out] phAsr2Sem Pointer to the Asr2Sem handle.
 *  The pointer is set to \p (void*)0 when the function returns.
 *
 * \return see \ref ErrorHandling
 */
LH_ERROR a2s_Asr2SemClose2(PASR2SEM2* phAsr2Sem);
/**@}*/
